package com.jiaai.cloud.wx.entity;


import java.util.ArrayList;
import java.util.Arrays;


import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.jiaai.cloud.base.configurer.DateFormat;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-08-31
 */
@TableName("t_wxcomment")
public class TWxcomment extends Model<TWxcomment> {

    private static final long serialVersionUID = 1L;

    /**
     * 商店评论id
     */
    @TableId(value = "id", type= IdType.AUTO)
	private Integer id;
    /**
     * 评论的用户id
     */
	private Integer userid;
    /**
     * 被评论的商店id
     */
	private Integer shopid;
    /**
     * 评论的内容
     */
	private String content;
    /**
     * 评论的分数
     */
	private Integer score;
    /**
     * 评论的时间
     */
	@JSONField(format = "YYYY-MM-dd HH:mm:ss")
	private Date comdate;
    /**
     * 评论的图片
     */
    @JSONField(serialize = false)
	private String imgs;


	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getUserid() {
		return userid;
	}

	public void setUserid(Integer userid) {
		this.userid = userid;
	}

	public Integer getShopid() {
		return shopid;
	}

	public void setShopid(Integer shopid) {
		this.shopid = shopid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}


	public Date getComdate() {
		return comdate;
	}

	public void setComdate(Date comdate) {
		this.comdate = comdate;
	}

	public String getImgs() {
		return imgs;
	}

	public void setImgs(String imgs) {
		this.imgs = imgs;
	}

	@Override
	protected Serializable pkVal() {
		return this.id;
	}

	/**
	 *
	 * @return
	 */
	public List<String> getPiclist() {
		if(StringUtils.isEmpty(imgs)){
			return this.piclist;
		}
		if( imgs.indexOf(",") <= 0 ){
			this.piclist.add(this.imgs);
			return this.piclist;
		}
		return Arrays.asList(this.imgs.split(","));

	}

	public void setPiclist(List<String> piclist) {
		this.piclist = piclist;
	}

	/**
	 * 评论图片url数组
	 */
	@TableField(exist = false)
	private List<String> piclist = new ArrayList<>();

	/**
	 * 评论对应的用户
	 */
	@TableField(exist = false, value = "usernickname")
	private String usernickname;

	public String getUsernickname() {
		return usernickname;
	}

	public void setUsernickname(String userNickname) {
		this.usernickname = userNickname;
	}

	/**
	 * 评论用户的头像
	 */
	@TableField(exist = false, value = "useravater")
	private String useravater;

	public String getUseravater() {
		return useravater;
	}

	public void setUseravater(String useravater) {
		this.useravater = useravater;
	}
}
